//引入路由api
import path from "path";
import { createRouter, createWebHashHistory } from "vue-router";

//引入页面
const Home = () => import('../views/Home.vue')
const About = () => import('../views/About.vue')
const UserCenter = () => import('../views/user-center/index.vue')
const UserProfile = () => import("../views/user-center/Profile.vue")
const UserSettings = () => import("../views/user-center/Settings.vue")
const VuexPage = () => import('../views/Vuex.vue')
const ElementTest = () => import('../views/ElementTest.vue')
const ListDemo = () => import('../views/ListDemo.vue')
const Register =() => import('../views/Register.vue')
const AccountList = () => import('../views/AccountList.vue')


//路由配置
const routes = [
 {path:'/', redirect:'/home'},
 {path: '/home', name:'home', component: Home},
 {path: '/about', name:'about', component: About},
 {path:'/element',name:'element',component:ElementTest},
 {path:'/list-demo',name:'listDemo',component:ListDemo},
 {path:'/register',name:'register',component:Register},
 
 {path:'/account-list',name:'accountList',component:AccountList},
 { path: '/vuex', name: 'vuex', component: VuexPage },

 {path: '/user', 
 name:"userCenter", 
 component: UserCenter,
 redirect:'/user/Profile',
 chlidren: [
    {
       path:"Profile",
       name:"Profile",
       component: UserProfile
    },
    {
        path:"Settings",
        name:"Settings",
        component:UserSettings
    },
 ]
},

 
]

//创建路由实例
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})

export default router